#include "ObjectTypeUtils.h"

bool ObjectTypeUtils::isSquare(ObjectType &obj){
		return obj==square;
	}

bool ObjectTypeUtils::isRectangle(ObjectType &obj){
	return obj==rectangle;
}

bool ObjectTypeUtils::isTexture(ObjectType &obj){
	return obj==texture;
}

bool ObjectTypeUtils::isSegment(ObjectType &obj){
	return obj==segment;
}


bool ObjectTypeUtils::isCircle(ObjectType &obj){
	return obj==circle;
}

bool ObjectTypeUtils::isFigure(ObjectType &obj){
	return ((obj==square)||(obj==segment)||(obj==rectangle)||(obj==circle));
}

bool ObjectTypeUtils::isGeneralTag(ObjectType &obj){
	return (obj==general);
}


std::string stringToLower(std::string strToConvert)
{//change each element of the string to lower case
   for(unsigned int i=0;i<strToConvert.length();i++)
   {
      strToConvert[i] = tolower(strToConvert[i]);
   }
   return strToConvert;//return the converted string
}

ObjectType ObjectTypeUtils::getObjectTypeByString(std::string type) throw (InvalidObjectTypeException){
	
	type = stringToLower(type);
	if (type.compare("circulo")==0)
		return circle;
	if (type.compare("cuadrado")==0)
		return square;
	if (type.compare("segmento")==0)
		return segment;
	if(type.compare("rectangulo")==0)
		return rectangle;
	if(type.compare("textura")==0)
		return texture;
	if(type.compare("general")==0)
		return general;
	if(type.compare("posicion")==0)
		return position;
	if(type.compare("inicio")==0)
		return begin;
	if(type.compare("fin")==0)
		return end;
	if(type.compare("resolucion")==0)
		return resolution;
	if(type.compare("colorlinea")==0)
		return lineColor;
	if(type.compare("colorfondograf")==0)
		return screenColor;
	if(type.compare("colorfondo")==0)
		return figureColor;
	
	else 
		throw InvalidObjectTypeException("El tipo de Objeto ' "+type+" ' es inexistente");
}
